<div class="row"> <h3 class="page-header">教研室管理</h3></div>
<div class="row">
    <div class="panel panel-default">
        <div class="panel-body">
            <label><a class="btn btn-primary addText">添加</a></label>
            <form action='{:U("Dep/index")}' class="form-inline text-right fr m-b-5">
                名称：<input type="text" name='name' value='{$Think.get.name}' class="form-control mr20 w150" >
                <button class="btn btn-primary" type="submit">搜索</button>
            </form>
            <div class="table-responsive">
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                    <tr>
                        <th width="60">序号</th>
                        <th>部门名称</th>
                        <th>备注</th>
                        <th width="75">排序</th>
                        <th width="120">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <empty name="list">
                         <tr><td colspan="5" align="center">暂无信息</td></tr>
                     </empty>
                    <volist name="list" id="list">
                        <tr>
                            <td>{:bcadd($i,bcmul(12,bcsub(I("p",1,"intval"),1)))}</td>
                            <td style="text-align: left;padding-left:{:18 * $list['num']}px;">|-{$list.name}</td>
                            <td><empty name='list.descr'>无<else/>{$list.descr}</empty></td>
                            <td><input class="setSort" type="text" size="2" data-url="{:U('Classify/setSort?id='.$list['id'])}" value="{$list.sort}"></td>
                            <td>
                                <a class=" btn btn-default btn-sm editText" data-id='{$list.id}'>修改</a>
                                <button data-url='{:U("Dep/del?id=".$list["id"])}' class="btn-sm btn btn-default delBtn" type="button">删除</button>
                            </td>
                        </tr>
                    </volist>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<div id="myModal" class="modal fade in" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <form action="{:U('Dep/add')}" id="myform" class="form-horizontal" data-callback="_form_defult_callback">
                <div class="modal-header">
                    <button data-dismiss="modal" class="close" type="button">×</button>
                    <h4 class="modal-title">教研室信息</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group" id="xb">
                        <label class="col-sm-3 control-label">系部：</label>
                        <div class="col-sm-4 input-group">
                            <select class="form-control" name="pid">
                                <option value="0">无上级</option>
                                <volist name="depList" id="_dep">
                                    <option value='{$_dep.id}' <eq name='Think.get.dep_id' value="$_dep.id">selected</eq>><for start = "1" end = "$_dep['num']">&nbsp;&nbsp;</for>|-{$_dep.name}</option>
                                </volist>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">名称：<span class="c-red">*</span></label>
                        <div class="col-sm-6 input-group">
                            <input class="form-control required" name="name">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">排序：</label>
                        <div class="col-sm-4 input-group">
                            <input class="form-control digits" name="set_sort" value="100">
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">状态：</label>
                        <div class="col-sm-4 input-group">
                            <label class="radio-inline">
                                <input type="radio" value="1" name="set_status" checked>启用
                            </label>
                            <label class="radio-inline">
                                <input type="radio" value="0" name="set_status">禁用<BR>
                            </label>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button data-dismiss="modal" class=" btn btn-default" type="button">关闭</button>
                    <button class="btn btn-primary" type="submit">保存</button>
                </div>
                <input type="hidden" name="id" />
            </form>
        </div>
    </div>
</div>
<script>
    $(function(){
        $('.addText').click(function(){
            $('#myform')[0].reset();
            $('#myModal').modal('show');
        });
        $('.editText').click(function(){
            $('#myform')[0].reset();
            var id = $(this).data('id'); waiting();
            $.get('{:U("Dep/edit")}', {id: id}, function(data){
                complete();
                if(data.status == 1){
                    var _get_info = data.info;
                    if(_get_info.pid == '0'){
                        $("#xb").hide();
                    }else{
                        $("#xb").show();
                    }
                    $('#myform input[name="id"]').val(_get_info.id);
                    $('#myform select[name="pid"]').val(_get_info.pid);
                    $('#myform input[name="name"]').val(_get_info.name);
                    $('#myform input[name="set_sort"]').val(_get_info.sort);
                    $("#myform :radio[name=set_status][value='"+_get_info.status+"']").attr("checked",true)
                    $('#myform').attr('action', '{:U("Dep/edit")}');
                    $('#myModal').modal('show');
                }else{
                    showInfo(data.info);
                    setTimeout('_form_defult_callback()', 1600);

                }
            });
        })
    });

</script>